package com.yarolegovich.lovelydialog;

import ohos.agp.components.Component;
import ohos.agp.window.dialog.IDialog;

/**
 * Created by yarolegovich on 23.02.2017.
 */

public class LovelyDialogCompat {
    /**
     * If you don't want to change implemented interfaces when migrating from standard dialogs
     * to LovelyDialogs - use this method.
     *
     * @param listener listener
     * @return clickListener
     */
    public static Component.ClickedListener wrap(IDialog.ClickedListener listener) {
        return new DialogOnClickListenerAdapter(listener);
    }

    public static class DialogOnClickListenerAdapter implements Component.ClickedListener {
        private IDialog.ClickedListener adapted;
        DialogOnClickListenerAdapter(IDialog.ClickedListener adapted) {
            this.adapted = adapted;
        }
        public void onClick(IDialog dialogInterface, int which) {
            if (adapted != null) {
                adapted.onClick(dialogInterface, which);
            }
        }
        @Override
        public void onClick(Component component) {

        }
    }
}
